package cn.wolfcode.wolf2w.web.controller;


import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IRegionService regionService;


    /**
     * 罗列出热门目的地的区域
     * @return
     */
    @GetMapping("hotRegion")
    public Object hotRegion(){

        List<Region> list = regionService.queryHotRegion();
        return JsonResult.success(list);
    }

    /**
     * 通过区域id查询目的地的对象集
     * @param regionId
     * @return
     */
      @GetMapping("search")
    public Object search(String regionId){

        List<Destination> destinations = destinationService.queryDesByRegIdOnApi(regionId);
        return JsonResult.success(destinations);
    }

    /**
     * 导航吐司
     */
    @GetMapping("toasts")
    public Object toasts(String destId){

        List<Destination> list = destinationService.queryDesByParentId(destId);
        return JsonResult.success(list);
    }



    /**
     *通过目的地查询攻略分类
     * @param destId
     * @return
     */
    @GetMapping("catalogs")
    public Object catalogs(String destId){

        List<StrategyCatalog> strategyCatalogs = destinationService.queryCatalogByDestId(destId);
        return  JsonResult.success(strategyCatalogs);
    }

    /**
     * 根据目的地,显示点击量前三的攻略文章
     * @param destId
     * @return
     */
    @GetMapping("strategies/viewnumTop3")
    public Object viewnumTop4(String destId){
        List<Strategy> strategies = destinationService.queryViewunmTop3(destId);
        return JsonResult.success(strategies);
    }

    /**
     * 根据目的地,显示点击量前三的游记文章
     * @param destId
     * @return
     */
    @GetMapping("travels/viewnumTop3")
    public Object viewnumTop(String destId){
        List<Travel> travels = destinationService.queryTravelsToViewingTop3(destId);
        return JsonResult.success(travels);
    }


}
